﻿using System;
using System.Windows.Forms;
using ApplicationGenerator.Versions.BusinessLogic;

namespace ApplicationGenerator.Versions.Forms
{
    /// <summary>
    /// Formatka wyświetlająca kontrolkę z wersjami danego typu
    /// </summary>
    public partial class VersionForm : Form
    {
        public VersionForm()
        {
            InitializeComponent();
        }

        public VersionElement VersionType
        {
            set;
            get;
        }

        public void InitializeVersions()
        {
            ctlVersionControl.VersionType = VersionType;
            ctlVersionControl.InitializeVersionElements();
        }

        public VersionInfo SelectedVersionInfo
        {
            get;
            set;
        }

        private void ctlCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void ctlOk_Click(object sender, EventArgs e)
        {
            if (!ctlVersionControl.IsVersionSelected())
            {
                MessageBox.Show("Należy wybrać element.");
                return;
            }

            SelectedVersionInfo = ctlVersionControl.GetVersionInfo();
            DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
